﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;

using RRRSRoguelike.Managers;
using RRRSRoguelikeData;

namespace RRRSRoguelike.Entities
{
	/// <summary>
	/// Describes the dungeon object.
	/// </summary>
	class Dungeon
	{
		public DungeonData Data;
		public List<DungeonLevel> Levels;

		public Dungeon()
		{
			Levels = new List<DungeonLevel>();
		}

		public void LoadData(string fileName)
		{
			Data = Files.ReadDataFromXML(Path.Combine(Properties.Settings.Default.CustomFolder, fileName,fileName+".xml"));
		}


		/// <summary>
		/// Sets up dungeon layers according to data
		/// </summary>
		public void SetupLayers()
		{
			var i = 1;
			foreach (var s in Data.Levels)
			{
				//TODO: write a switch statement to handle different types of levels
				if (s == "Random")
				{
					Levels.Add(new DungeonLevel(i, Constants.DungeonWidth, Constants.DungeonHeight));
				}
				i++;
			}
		}
		
		public void SetupSound()
		{
			int i = 1;
			foreach (KeyValuePair<string,string> s in Data.Sounds)
			{
				GameManager.Instance.SoundManager.AddCustomSound(
					s.Key,
					Path.GetFileName(s.Value));
			}
			
		}
	}
}
